package org.itboys.mobile.service;

import org.itboys.admin.tools.AdminSessionHolder;
import org.itboys.commons.utils.tools.LongUtil;
import org.itboys.mobile.common.SundayCommonConstants;
import org.itboys.mobile.dao.order.SundayOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;


/**
 * 作者：jiangxiong
 * 日期：2016年11月7日
 * 联系方式 ：empty90911@126.com
 * 描述：圣代_提醒（含订单待配送）_service
 */
@Service
public class SundayAlertService {
	/**
	 * 页面控制时间，定时获取订单待配送消息；
	 * @param zoneId
	 * @return
	 */
	@Autowired
	private SundayOrderMapper orderMapper;;

	/**
	 * 获取提醒信息（订单提醒）
	 * @param loginUserId
	 * @return
	 */
	public Map<String,Integer> getAlertInfo(){
		Map<String,Integer> result = new HashMap<String, Integer>();

		//result.put("sos", 0l);
		//是否有待配送订单
		Integer isOrder= 0;
		//获取当前登录信息
		Long loginShopId = AdminSessionHolder.getPlatformMemberId();
		if(LongUtil.isNull(loginShopId)){
			return result;
		}
		Map<String,Object> param = new HashMap<String, Object>();
		param.put("shopId",loginShopId);
		param.put("status", SundayCommonConstants.ORDER_STATUS_DFH);
		Serializable order = orderMapper.count(param);
		if(order!=null&&Long.valueOf(order.toString())>0){
			isOrder=1;
		}
		result.put("isOrder",isOrder);
		return result;
	}
}
